import * as ActionTypes from '../../../constants/constants.js'
import * as util from '../../../util/utils.js'

export const shoppingCartList = (state = { cartItemList: [], productPrice: '' }, action) => {
    switch (action.type) {
        case ActionTypes.shoppingCartList:
            return action.data
        case ActionTypes.shoppingCartListRefresh:
            return action.data
        case ActionTypes.shoppingCartListError:
            state.error = action.data.error
            return {
                ...state,
                ...action.data
            }
        case ActionTypes.shoppingCartListReset:
            return {
                pageNum: 0,
                nextPage: 1,
                pageSize: 10,
                list: []
            }
        default:
            return state;
    }
}
